//package com.zws.cucumber.spring.jetty9;
//
//import com.zws.cucumber.util.colorfullog.ZwsColorfulLogger;
//import org.slf4j.Logger;
//
//import javax.servlet.*;
//import javax.servlet.http.HttpServletResponse;
//import java.io.IOException;
//
//public class ZwsQuickResponseFilter implements Filter {
//
//    private static final Logger logger = ZwsColorfulLogger.of(ZwsQuickResponseFilter.class);
//
//    private static volatile boolean enable = false;
//
//    public static void enable() {
//        enable = true;
//    }
//
//    public static void disable() {
//        enable = false;
//    }
//
//    @Override
//    public void init(FilterConfig filterConfig) throws ServletException {
//        // no operation, adapt to low version of servlet api
//    }
//
//    @Override
//    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
//            throws IOException, ServletException {
//
//        if (enable) {
//            logger.debug("enable ZwsQuickResponseFilter, do filter");
//            HttpServletResponse httpResp = (HttpServletResponse) response;
//            httpResp.setStatus(200);
//            httpResp.getOutputStream().print("\"Ok from ZwsQuickResponseFilter\"");
//            httpResp.getOutputStream().flush();
//            httpResp.getOutputStream().close();
//        } else {
//            logger.trace("disable ZwsQuickResponseFilter, do filter");
//            chain.doFilter(request, response);
//        }
//    }
//}
